package ch10_10_9;
import java.util.Date;
public class findMax{
	@SuppressWarnings("deprecation")
	public static void main(String[] args){
		String[] stringArray={"Apple", "Orange", "Banana", "Grape", "Pineapple",
				"Pear", "Peach", "Apricots", "Watermelon", "Muskmelon"};
		
		Integer[] intArray={new Integer(2), new Integer(4), new Integer(3),
				new Integer(1), new Integer(10), new Integer(7), 
				new Integer(13), new Integer(2), new Integer(5), new Integer(3)};
		
		Date[] dateArray={new Date(2010,1,1), new Date(2010,1,23), new Date(1989,2,9),
				new Date(1999,3,4), new Date(2000,3,4), new Date(1997,12,20),
				new Date(1999,7,1), new Date(2008,8,8), new Date(2012,12,20),
				new Date(2000,12,9)};
		
		System.out.println("The largest string is: "+max(stringArray));
		System.out.println("The largest integer is: "+max(intArray));
		System.out.println("The largest date is: "+max(dateArray));
	}
	
	@SuppressWarnings("unchecked")
	public static Object max(Object[] a){
		Object max=a[0];
		for(int i=1; i<a.length; i++)
			if(((Comparable<Object>)max).compareTo(a[i])<0)
				max=a[i];
		return max;
	}
}